using System.IO;
using System.Web.UI;
using Library.WebControls.SimplePaging;
using System.Web.UI.HtmlControls;

namespace Library.WebControls.SimpleDataView {
	public class SpDataViewDesign : System.Web.UI.Design.ControlDesigner {
		public override string GetDesignTimeHtml() {
			var dv = (SpDataView)Component;
			return GetDesignTimeHtml(dv);
		}

		internal static string GetDesignTimeHtml(SpDataView dv) {
			var sw = new StringWriter();
			var tw = new HtmlTextWriter(sw);

			var divDataView = new HtmlGenericControl("div");
			divDataView.Attributes["class"] = "spdataview";
			//divDataView.Style[HtmlTextWriterStyle.Width] = dv.Width.ToString();
			var divContent = new HtmlGenericControl("div");
			divContent.Attributes["class"] = "spdv-content";
			var divPaging = new HtmlGenericControl("div");
			divPaging.Attributes["class"] = "spdv-paging";
			divDataView.Controls.Add(divContent);
			divContent.Controls.Add(divPaging);

			var divPagingContent = new HtmlGenericControl("div");
			divPaging.Controls.Add(divPagingContent);
			divPagingContent.Attributes["class"] = "spdv-paging-content";
			var pagingControl = new SpPaging();
			divPagingContent.Controls.Add(pagingControl);
			
			
			dv.CreateCssLink().RenderControl(tw);
			divDataView.RenderControl(tw);

			
			return sw.ToString();
		}
	}
}
